﻿<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:s="clr-namespace:System;assembly=mscorlib"
	xmlns:local="clr-namespace:Charts"
	xmlns:conv="clr-namespace:Charts.Converters"
>
	<ResourceDictionary.MergedDictionaries>
		<ResourceDictionary Source="..\Resources\Theme.xaml"/>
	</ResourceDictionary.MergedDictionaries>
	
	<Style TargetType="local:LineGraph">
		
		<Setter Property="ItemsSource" Value="{Binding}"/>
		
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="ItemsControl">
					<Grid>
						<Canvas>
							<Polyline Style="{StaticResource polyLineStyle}">
								<Polyline.Points>
									<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type ItemsControl}}"
									         Path="Points"/>
								</Polyline.Points>
							</Polyline>
							
							<Path Style="{StaticResource markersSetStyle}">
								<Path.Data>
									<GeometryGroup>
										<GeometryGroup.Children>
											<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type ItemsControl}}"
											         Path="Points"
											         ConverterParameter="{StaticResource marker}"
											         Converter="{conv:PointsToMarkersConverter}"/>
										</GeometryGroup.Children>
									</GeometryGroup>
								</Path.Data>
							</Path>
						
						</Canvas>
						<ItemsPresenter/>
					
					</Grid>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
		
		<Setter Property="ItemsControl.ItemsPanel">
			<Setter.Value>
				<ItemsPanelTemplate>
					<UniformGrid IsItemsHost="True" Columns="{Binding Count}"/>
				</ItemsPanelTemplate>
			</Setter.Value>
		</Setter>
		
		<Setter Property="ItemsControl.ItemContainerStyle">
			<Setter.Value>
				<Style TargetType="ContentPresenter">
					
					<Setter Property="VerticalAlignment" Value="Top"/>
					<Setter Property="HorizontalAlignment" Value="Center"/>
					<Setter Property="Effect" Value="{StaticResource shadow}"/>
					
					<Setter Property="RenderTransform">
						<Setter.Value>
							<TranslateTransform>
								<TranslateTransform.Y>
									
									<MultiBinding ConverterParameter="{StaticResource labelShift}" Converter="{conv:YValueLabelConverter}">
										
										<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type ContentPresenter}}"
										         Path="ActualHeight"/>
										<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type local:LineGraph}}"
										         Path="ActualHeight"/>
										<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type local:LineGraph}}"
										         Path="Maximum"/>
										<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type local:LineGraph}}"
										         Path="Minimum"/>
										<Binding Path="{StaticResource valuePath}"/>
									
									</MultiBinding>
								
								</TranslateTransform.Y>
							</TranslateTransform>
						</Setter.Value>
					</Setter>
				</Style>
			</Setter.Value>
		</Setter>
		
		<!--<Setter Property="ItemsControl.ItemTemplate">
			<Setter.Value>
				<DataTemplate>
					
					<Border BorderThickness="2" CornerRadius="2" BorderBrush="White" Background="DarkBlue" Effect="{StaticResource shadow}" SnapsToDevicePixels="True" >
						<TextBlock Effect="{StaticResource shadow}" SnapsToDevicePixels="True">
							<TextBlock.Text>
								<Binding Path="{StaticResource valuePath}" StringFormat="{StaticResource stringFormat}"/>
							</TextBlock.Text>
						</TextBlock>
					</Border>
						
				</DataTemplate>
			</Setter.Value>
		</Setter>-->
		
		<!--<Setter Property="DisplayMemberPath" Value="Value"/>-->
		
		<Setter Property="Points">
			<Setter.Value>
				<MultiBinding Converter="{conv:PointsConverter}">
					
					<Binding RelativeSource="{RelativeSource Self}"
					         Path="ActualHeight"/>
					<Binding RelativeSource="{RelativeSource Self}"
					         Path="ActualWidth"/>
					<Binding RelativeSource="{RelativeSource Self}"
					         Path="Maximum"/>
					<Binding RelativeSource="{RelativeSource Self}"
					         Path="Minimum"/>
					<Binding RelativeSource="{RelativeSource Self}"
					         Path="Values"/>
				
				</MultiBinding>
			</Setter.Value>
		</Setter>
	
	</Style>

</ResourceDictionary>